$(document).ready(function () {
    $('#btn_close').click(function () {
        window.appApi.rendererSend('close-countdown-setting-window');
    })
    window.appApi.getAppSetting('countdown').then(function (value) {
        let countdownSeconds = 10 * 60;
        if (value['time']) {
            countdownSeconds = value['time'];
        }
        $('input[name=time]').val(countdownSeconds / 60);
    });
    $('#reset_countdown_setting').click(function () {
        $('input[name=time]').val(10);
    });
    $('#submit_countdown_setting').click(async function () {
        const countdownTime = $('#countdown_setting_form input[name=time]').val();
        await window.appApi.setAppSetting('countdown', 'time', countdownTime * 60)
        // 发送事件
        window.appApi.rendererSend('submit-countdown-setting', {time: countdownTime * 60});
    });
});